< previous page page_136 next page >

Page 136
Using the CoolBar Control
The CoolBar control, pictured earlier in Figure 6.11, is a special control that acts as a container for other controls but looks like a toolbar. The CoolBar control itself does not have "built-in" Button objects like a toolbar does. However, since the coolbar is a container control, it can contain objects such as command buttons and even toolbars.
The CoolBar control contains a collection of Band objects, each of which is a mini-container that the user can resize at runtime.
To illustrate how the CoolBar control can contain other controls, let's extend the example from the earlier part of the chapter. Follow these steps:
1. If you haven't done so already, add the CoolBar control to the Toolbox by selecting Microsoft Windows Common Controls 3 6.0 from the Components dialog box.
2. Change the Align property of the toolbar you created earlier to 0 vbAlignNone. Drag it to an open area of the form and adjust its width so it is just wide enough to display the buttons you added earlier.
3. Double-click the coolbar icon in the Toolbox to add a CoolBar control to your form.
4. Click the CoolBar control to select it. Click the CommandButton icon and draw a command button directly on the coolbar.
5. Create a simple Click event procedure for the command button, adding a line of code like MsgBox "You clicked Command1".
6. Right-click the toolbar and select Cutto remove it from the form, placing it on the Windows Clipboard.
7. Right-click the CoolBar control and select Paste. The toolbar from the Clipboard is pasted into the coolbar container.
8. Right-click a blank area of the CoolBar control (don't click the contained toolbar or command button). Select Properties to display the coolbar's Property Pages dialog box.
9. The Bands tab of the Property Pages dialog box contains properties for each of the CoolBar control's bands. Band 1 should be selected in the Index box at the top. Drop down the Childlist and select tbrDemo. This action instructs the coolbar to display tbrDemo in the Band 1 mini-container.
10. Change the index to 2 to select the second band. Set its Child property to Command1 (the command button you added earlier).
11. Click OK to close the Property Pages dialog box. While the CoolBar control is still selected, go to the Properties window and change its Align property to 1 vbAlignTop.
When you have completed these steps, run the program and observe the behavior of the objects on the CoolBar control. You can experiment with placing different types of objects on a CoolBar control in your applications.

 
< previous page page_136 next page >